package com.ruoyi.api.mail;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.JiajiaPointsFlow;
import com.ruoyi.system.service.IJiajiaPointsFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 项目积分流水Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@Controller
@RequestMapping("/api/mall/points")
public class ApiJiajiaPointsFlowController
{

    @Autowired
    private IJiajiaPointsFlowService jiajiaPointsFlowService;



    /**
     * 查询项目积分流水列表
     */
    @PostMapping("/list")
    @ResponseBody
    public List<JiajiaPointsFlow> list(JiajiaPointsFlow jiajiaPointsFlow)
    {
        List<JiajiaPointsFlow> list = jiajiaPointsFlowService.selectJiajiaPointsFlowList(jiajiaPointsFlow);
        return list;
    }

    /***
     * 可用积分
     * @param
     * @return
     */
    @PostMapping( "/available")
    @ResponseBody
    public AjaxResult available()
    {
        return AjaxResult.success(jiajiaPointsFlowService.selectAvailablePoints());
    }


    @PostMapping( "/total")
    @ResponseBody
    public AjaxResult total()
    {
        return AjaxResult.success(jiajiaPointsFlowService.selectTotalPoints());
    }

    /**
     * 导出项目积分流水列表
     */
    @Log(title = "项目积分流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaPointsFlow jiajiaPointsFlow)
    {
        List<JiajiaPointsFlow> list = jiajiaPointsFlowService.selectJiajiaPointsFlowList(jiajiaPointsFlow);
        ExcelUtil<JiajiaPointsFlow> util = new ExcelUtil<JiajiaPointsFlow>(JiajiaPointsFlow.class);
        return util.exportExcel(list, "项目积分流水数据");
    }


    /**
     * 新增保存项目积分流水
     */
    @Log(title = "项目积分流水", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaPointsFlow jiajiaPointsFlow)
    {
        return AjaxResult.success(jiajiaPointsFlowService.insertJiajiaPointsFlow(jiajiaPointsFlow));
    }



    /**
     * 修改保存项目积分流水
     */
    @Log(title = "项目积分流水", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaPointsFlow jiajiaPointsFlow)
    {
        return AjaxResult.success(jiajiaPointsFlowService.updateJiajiaPointsFlow(jiajiaPointsFlow));
    }

    /**
     * 删除项目积分流水
     */
    @Log(title = "项目积分流水", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return AjaxResult.success(jiajiaPointsFlowService.deleteJiajiaPointsFlowByIds(ids));
    }



}
